<template>
	<view class="tuiyajin">
		<headertop title="退押金" str1="oridei" :back1="back1"></headertop>
		<view class="tuiyajinback">

		</view>
		<view class="infocontent" v-if="typestr == '押金列表'">
			<image :src="contentobj.file.image" mode=""></image>
			<view class="texts">
				<view class="t1">
					<view class="gu" v-if="contentobj.file.typename=='固'">
						固
					</view>
					<span>{{contentobj.file.cname}}</span>
				</view>
				<view class="t2">
					{{contentobj.file.detail}}
				</view>
				<view class="t3">
					<span>押金：￥{{contentobj.file.deposit}}</span>
					<span style="display: flex;align-items:center;">场地费：<span
							style="font-weight: bold;font-size: 32rpx;color: #7EBC79;">￥{{contentobj.file.price}}</span></span>
				</view>
			</view>
		</view>

		<view class="" v-if="typestr=='zuli'" style="width: 100%;margin-top: 190rpx;">
			<view class="infocontent" v-for="item in arrcontent" :key="item.id">
				<image :src="item.image" mode=""></image>
				<view class="texts">
					<view class="t1">

						<span>{{item.title}}</span>
					</view>
					<view class="t2">
						{{item.detail}}
					</view>
					<view class="t3">
						<span>押金：￥{{item.deposit}}</span>
						<span style="display: flex;align-items:center;">场地费：<span
								style="font-weight: bold;font-size: 32rpx;color: #7EBC79;">￥{{item.price}}</span></span>
					</view>
				</view>
			</view>
		</view>

		<view class="" v-if="typestr != '押金列表'&&typestr!='zuli'" style="width: 100%;margin-top: 190rpx;">
			<view class="infocontent" v-for="item in arrcontent" :key="item.id">
				<image :src="item.image" mode=""></image>
				<view class="texts">
					<view class="t1">
						<view class="gu" v-if="item.typename=='固'">
							固
						</view>
						<span>{{item.cname}}</span>
					</view>
					<view class="t2">
						{{item.detail}}
					</view>
					<view class="t3">
						<span>押金：￥{{item.deposit}}</span>
						<span style="display: flex;align-items:center;">场地费：<span
								style="font-weight: bold;font-size: 32rpx;color: #7EBC79;">￥{{item.price}}</span></span>
					</view>
				</view>
			</view>
		</view>


		<view class="jinebox">
			<view class="danwei">￥</view>
			<input type="digit" v-model="contentobj.deposit" :disabled="true" laceholder="请输入金额" />
		</view>

		<view class="fixedbox">
			<view class="centerbox" @click="ljsq1">
				立即申请
			</view>
		</view>
	</view>
</template>
<script setup>
	import headertop from '@/components/header.vue'
	import {
		onPageScroll,
		onLoad
	} from "@dcloudio/uni-app";
	import {
		orderfile,
		tuiya
	} from '@/api/Campposition.js'
	import {
		orderfile1,
		tuiya1
	} from '@/api/lease.js'
	import {
		tuiya3
	} from '@/api/my.js'
	import {
		ref
	} from 'vue'
	const back1 = ref('')
	const money = ref('')
	const arrcontent = ref([])
	const contentobj = ref({})
	const str = ref('')
	const typestr = ref('')
	onPageScroll((e) => {
		if (e.scrollTop > 100) {
			back1.value = '#84BD78'
		} else {
			back1.value = ''
		}
	})
	onLoad((opt) => {
		console.log(opt, 'eeeeeeeeeeeeeee');
		typestr.value = opt.typestr
		init(opt.id)
		str.value = opt.str
	})

	function ljsq1() {
		uni.showModal({
			title: '提示', // 标题（可选）
			content: '确定要申请吗？', // 内容（可选）
			confirmText: '确定', // 确认按钮文字（可选，默认“确定”）
			cancelText: '取消', // 取消按钮文字（可选，默认“取消”）
			success: (res) => {
				if (res.confirm) {
					ljsq()
					// 执行确定后的逻辑
				} else if (res.cancel) {
					console.log('用户点击了取消');
					// 执行取消后的逻辑
				}
			},
			fail: (err) => {
				console.error('弹窗调用失败', err);
			}
		});
	}
	async function init(id) {
		var res = ''
		if (typestr.value == 'zuli') {
			res = await orderfile1({
				id
			})
		} else {
			res = await orderfile({
				id
			})
		}

		if (res.data.code == 1) {
			arrcontent.value = res.data.data.orderfile
			contentobj.value = res.data.data.order
		}
	}
	async function ljsq() {




		var res = ''
		if (typestr.value == 'zuli') {
			res = await tuiya1({
				id: contentobj.value.id,
				money: contentobj.value.deposit
			})
		} else {
			res = await tuiya({
				id: contentobj.value.id,
				money: contentobj.value.deposit
			})
		}
		if (res.code == 0) {
			uni.showToast({
				title: res.msg,
				icon: 'none'
			})
			return
		}
		if (res.data.code == 1) {
			setTimeout(() => {
				uni.showToast({
					title: '申请成功',
					icon: 'none'
				})
			}, 500)
			if (str.value == 'orderlist') {
				uni.navigateTo({
					url: '/sub_my/my/yingweiorder?active=' + 3
				})
				return
			}
			uni.navigateBack()
		} else {
			uni.showToast({
				title: res.data.msg,
				icon: 'none'
			})
		}
	}
</script>

<style lang="scss">
	page {
		background: #F7F8FA;
	}

	.tuiyajin {
		width: 100%;
		overflow: hidden;
		position: relative;

		.fixedbox {
			width: 100%;
			height: 184rpx;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			overflow: hidden;
			position: fixed;
			bottom: 0%;

			.centerbox {
				width: 686rpx;
				height: 88rpx;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				text-align: center;
				line-height: 88rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				background: #7EBC79;
				font-size: 30rpx;
				color: #FFFFFF;
				margin: 22rpx auto;
			}
		}

		.tuiyajinback {
			width: 100%;
			height: 530rpx;
			background: linear-gradient(180deg, #84BD78 0%, rgba(132, 189, 120, 0) 100%);
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			position: absolute;
			z-index: -1;
		}

		.bzhu {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 26rpx;
			color: #86909C;
			width: 686rpx;
			margin: 22rpx auto;
		}

		.jinebox {
			width: 686rpx;
			height: 88rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 4rpx 4rpx 0rpx rgba(134, 202, 115, 0.43);
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin: auto;
			margin-top: 28rpx;
			display: flex;
			align-items: center;

			.danwei {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #1D2129;
				margin-left: 32rpx;
			}

			input {
				font-size: 32rpx;
				margin-left: 10rpx;
			}
		}

		.infocontent {
			width: 686rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 4rpx 4rpx 0rpx rgba(134, 202, 115, 0.43);
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			margin: auto;
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;
			padding: 20rpx 0;

			image {
				width: 198rpx;
				height: 176rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin-left: 24rpx;
			}

			.texts {
				width: 412rpx;
				margin-left: 24rpx;

				.t2 {
					font-weight: 400;
					font-size: 26rpx;
					color: #868686;
					white-space: nowrap;
					/* 禁止换行 */
					overflow: hidden;
					/* 隐藏溢出内容 */
					text-overflow: ellipsis;
					/* 超出用省略号表示 */
					width: 412rpx;
					margin-top: 28rpx;
				}

				.t3 {
					display: flex;
					font-weight: 400;
					font-size: 24rpx;
					color: #86909C;
					margin-top: 40rpx;
					font-weight: 400;
					font-size: 24rpx;
					color: #86909C;
					align-items: center;
					justify-content: space-between;
				}

				.t1 {
					display: flex;
					align-items: center;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #1D2129;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					/* 限制行数为2 */
					overflow: hidden;
					width: 412rpx;

					.gu {
						width: 48rpx;
						height: 32rpx;
						background: #7EBC79;
						border-radius: 4rpx 16rpx 4rpx 16rpx;
						line-height: 32rpx;
						font-size: 24rpx;
						color: #FFFFFF;
						text-align: center;
						margin-right: 4rpx;
					}
				}
			}
		}
	}
</style>